package multiples_colas;
// OOSimL v 1.1 File: Arrivals.java, Mon Mar 19 11:30:38 2012
 
import java.util.*; 
import psimjava.*; 
/** 
description
  The model of the multi-server multi-queue Customers-wash 
  OOSimL version J Garrido, Jan 2008

  This class defines the behavior of the environment
  that generates car arrivals, randomly.
  The object of this class creates and starts the car objects
  at specific instants called arrival events.
  An negative exponential distribution is used to generate 
  random numbers that correspond to the inter-arrival period.
  The service periods for car objects are random
  variables from a Uniform distribution.
  */
 public  class Arrivals  extends psimjava.Process     {
static Scanner scan = new Scanner (System.in);
 // car inter-arrival random period 
 // 
 private Erand arrivalPeriod; 
 // car service period random number  
 private Erand servicePeriod; 
 // 
 public Arrivals( String  arrname, double  Mean_arr, double  min_serv, double  max_serv) { 
 // 
 // create random number generator using mean inter-arrival period 
super(arrname); 
 // exponential distribution 
 //   
 // create random number generator using max and min service times 
arrivalPeriod = new Erand(Mean_arr);
 // Uniform distribution 
servicePeriod = new Erand(min_serv);
System.out.println(arrname+ 
" created");
 } // end initializer 
 // 
 public void  Main_body(   ) { 
 // inter-arrival period for car object 
 double  inter_arr; 
  // service period   
 double  serv_per; 
  double  simclock; 
  String  carname; 
  Customers carobj; 
 // display "Arrivals starting main body at: ", simclock 
 simclock = StaticSync.get_clock();
 // 
 while ( simclock < Multiples_colas.close_arrival ) { 
System.out.println("Arrivals to generate random values");
 // generate inter-arr 
 inter_arr = arrivalPeriod.fdraw(); 
  delay(inter_arr);
 // wait for inter-arr 
 // 
 Multiples_colas.num_arrived++;
 // generate service interval 
 serv_per = servicePeriod.fdraw(); 
simclock =  get_clock();
System.out.println("Arrivals creating Customers at: "+ 
simclock);
carname =  "Customers" + Multiples_colas.num_arrived;
 // 
carobj = new Customers(carname, serv_per);
 carobj.start();
System.out.println("Arrivals created car");
 } // endwhile 
System.out.println("Arrivals terminates");
  terminate();
 }  // end Main_body 
} // end class/interf Arrivals 
